//
//  FSDCollectionTableViewCell.m
//  NewsBar
//
//  Created by FSD on 15/12/11.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "FSDCollectionTableViewCell.h"

@implementation FSDCollectionTableViewCell

#pragma mark - 重写初始化方法init
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self createView];
    }
    return self;
}

#pragma mark - 创建视图
- (void)createView {
    self.title = [[UILabel alloc] initWithFrame:CGRectZero];
    self.title.font = [UIFont systemFontOfSize:18];
    self.title.numberOfLines = 2;
    self.CollectionImage = [[UIImageView alloc] initWithFrame:CGRectZero];
    self.kind = [[UILabel alloc] initWithFrame:CGRectZero];
    self.kind.font = [UIFont systemFontOfSize:14];
    self.kind.textAlignment = NSTextAlignmentRight;
    self.kind.alpha = 0.5;
    [self addSubview:self.title];
    [self addSubview:self.CollectionImage];
    [self addSubview:self.kind];

}

#pragma mark - set方法
- (void)setMineModel:(MineModel *)mineModel {
    if (_mineModel != mineModel) {
        _mineModel = mineModel;
    }
    self.title.text = mineModel.title;
    [self.CollectionImage sd_setImageWithURL:[NSURL URLWithString:mineModel.image] placeholderImage:[UIImage imageNamed:@"ImagePlace"]];
    self.kind.text = mineModel.kind;
}

#pragma mark - 重新布局
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.CollectionImage.frame = CGRectMake(10, 10, self.frame.size.width / 3 - 20, self.frame.size.height - 20);
    self.title.frame = CGRectMake(self.frame.size.width / 3, self.CollectionImage.frame.origin.y, self.frame.size.width - self.CollectionImage.frame.size.width - 20, (self.frame.size.height - 20) / 3 * 2);
    self.kind.frame = CGRectMake(self.frame.size.width / 3 * 2, self.title.frame.origin.y + self.title.frame.size.height + 10, self.frame.size.width / 3 - 10, (self.frame.size.height - 20) / 3);
    [self.CollectionImage nightMode];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
